# Create your models here.
from django.db import models


class Student(models.Model):
    class Meta:
        db_table = 'student'
    student_id = models.IntegerField(primary_key=True)
    name = models.CharField(max_length=30)
    age = models.IntegerField()

# @property
# def name(self):
#    return "[{} {}]".format(self.last_name, self.first_name)

    def __repr__(self):
        return '{} {} {}'. format(self.student_id, self.name, self.age)

    __str__ = __repr__


class Score(models.Model):
    class Meta:
        db_table = 'score'
    student_id = models.IntegerField(primary_key=True)
    course = models.CharField(max_length=30)
    score = models.FloatField()

    def __repr__(self):
        return '{} {} {}'. format(self.student_id, self.course, self.score)

    __str__ = __repr__


class Students(models.Model):
    class Meta:
        db_table = 'students'
    student_id = models.IntegerField(primary_key=True)
    name = models.CharField(max_length=30)
    age = models.IntegerField()

    def __repr__(self):
        return '{} {} {}'. format(self.student_id, self.name, self.age)

    __str__ = __repr__


class Scores(models.Model):
    class Meta:
        db_table = 'scores'
    # student_id = models.IntegerField(primary_key=True)
    student_id = models.ForeignKey(Students, on_delete=models.CASCADE)
    course = models.CharField(max_length=30)
    score = models.FloatField()

    def __repr__(self):
        return '{} {} {}'. format(self.pk, self.course, self.score)

    __str__ = __repr__


